

**************************************************************************************************************
*Table A_7: Effects on quality of ration received
*This table reports estimated treatment effects on the quality of commodities received by beneffciaries in endline one(January - March).
**************************************************************************************************************




**************************************************************************
* Adulteration 
**************************************************************************


*read in survey data 
use "${SurveyDataDir}/JH_ePOS_HH_DataforAnalysis.dta",clear

keep if ss_code == "SS01" //keep only if surveyed, omitting ghosts 
svyset [pw = pweight]


*Get relative weights of AAY and PH rationcard holders by whether RC is in an urban area
sum pweight if rationcardtype == "AAY" & isurban == 0
scalar AAY_weight0 = r(sum)

sum pweight if rationcardtype == "PH" & isurban == 0
scalar PH_weight0 = r(sum)

sum pweight if rationcardtype == "AAY" & isurban == 1
scalar AAY_weight1 = r(sum)

sum pweight if rationcardtype == "PH" & isurban == 1
scalar PH_weight1 = r(sum)


count
scalar obs = 3960 


loc ration "rice wheat sugar salt kero"

local tflist ""


foreach rat of local ration {
gen bl_var = d4_adulter_`rat'_ind_y0
egen bl_var_mean = mean(d4_adulter_`rat'_ind_y0)
gen bl_var_mi = missing(d4_adulter_`rat'_ind_y0)
replace bl_var = bl_var_mean if bl_var_mi == 1

qui svy: mean c26_adulterate_ind_`rat' if treatment == 0 
qui estat sd
matrix Mean0 = r(mean)


eststo mar_`rat'_indBL: xi: reg c26_adulterate_ind_`rat' treatment bl_var bl_var_mi i.strata [pw = pweight], cluster(block_code)
estadd scalar control_mean = `=Mean0[1,1]'
estadd scalar percent_obs 100*e(N)/obs

tempfile mar_`rat'_indBL
parmest, label saving("`mar_`rat'_indBL'")
local tflist "`tflist' `mar_`rat'_indBL'"

di in red "`tflist'"

drop bl_var*

}


*MHT q values
preserve

dsconcat `tflist', subset(parm p in 1) dsn(ds_ration) 
qqvalue p, method(yekutieli) qvalue(qval)
mkmat qval

forval i = 1/5 {
local estname: word `i' of `tflist'
local rat: word `i' of `ration'

estimates restore mar_`rat'_indBL


mat bet=e(b)                   

mat bet[1,1]=qval[`i',1]             
mat list bet      
estadd matrix qvalue = bet               
                                            
mat list e(qvalue)   

}

restore


******************************** Start multi panel table *********************************
loc tabname "${OutputDir}/TableA_7.tex" 
cd "${adoDir}"
loc nc 5
				
MultiPartTabStart, ///
			ncol(`nc') tabname(`tabname') ///
			colnames("Rice" "Wheat" "Sugar" "Salt" "Kerosene") width("\hsize")			
				
				
MultiPartTabPanelStart, ///
			ncol(`nc') tabname(`tabname') ///
			panelstring("Panel A: Adulteration")
			
MultiPartTabPanelEnd, ///
				ncol(`nc') tabname(`tabname') ///
				models("mar_rice_indBL mar_wheat_indBL mar_sugar_indBL mar_salt_indBL mar_kero_indBL") ///
				drop(_cons _Istrata* bl_var_mi bl_var) varlabels(treatment "Treatment" , elist(treatment \addlinespace) ) ///
				cells(b(star fmt(%12.2g) ) se(par(( )) fmt(%12.2g) ) qvalue(par([ ])  keep(treatment) fmt(2)) ) ///
				starlevels( * 0.10 ** 0.05 *** 0.01) ///
				stats(control_mean N percent_obs, label("Control mean" "Observations" "\% of sample") fmt(%12.2gc %15.0fc 0))



			
**************************************************************************
* Quality
**************************************************************************

*read in survey data 
use "${SurveyDataDir}/JH_ePOS_HH_DataforAnalysis.dta",clear

keep if ss_code == "SS01" //keep only if surveyed, omitting ghosts 
svyset [pw = pweight]


*Get relative weights of AAY and PH rationcard holders by whether RC is in an urban area
sum pweight if rationcardtype == "AAY" & isurban == 0
scalar AAY_weight0 = r(sum)

sum pweight if rationcardtype == "PH" & isurban == 0
scalar PH_weight0 = r(sum)

sum pweight if rationcardtype == "AAY" & isurban == 1
scalar AAY_weight1 = r(sum)

sum pweight if rationcardtype == "PH" & isurban == 1
scalar PH_weight1 = r(sum)




loc ration "rice wheat sugar salt kero"

local tflist_ind ""

foreach rat of local ration {

gen bl_var = c51_quality_`rat'_ind_y0
egen bl_var_mean = mean(bl_var)
gen bl_var_mi = missing(bl_var)
replace bl_var = bl_var_mean if bl_var_mi == 1

qui svy: mean c25_quality_`rat'_ind if treatment == 0 
qui estat sd
matrix Mean0 = r(mean)


eststo `rat'_qual_ind_bl: xi: reg c25_quality_`rat'_ind treatment bl_var bl_var_mi i.strata [pw = pweight], cluster(block_code)
estadd scalar control_mean = `=Mean0[1,1]'
estadd scalar percent_obs 100*e(N)/obs
drop bl_var*

tempfile mar_`rat'BL
parmest, label saving("`mar_`rat'BL'")
local tflist_ind "`tflist_ind' `mar_`rat'BL'"

}

preserve

dsconcat `tflist_ind', subset(parm p in 1) dsn(ds_ration)  
qqvalue p, method(yekutieli) qvalue(qval)
mkmat qval


*Main specification
forval i = 1/5 {
local estname: word `i' of `tflist_ind'
local rat: word `i' of `ration'

estimates restore `rat'_qual_ind_bl



mat bet=e(b)                   

mat bet[1,1]=qval[`i',1]             
mat list bet      
estadd matrix qvalue = bet               
                                            
mat list e(qvalue)
}
restore				

******************************** End multi panel table *********************************
	
				
MultiPartTabPanelStart, ///
			ncol(`nc') tabname(`tabname') ///
			panelstring("Panel B: Low quality")
			
MultiPartTabPanelEnd, ///
				ncol(`nc') tabname(`tabname') ///
				models("rice_qual_ind_bl wheat_qual_ind_bl sugar_qual_ind_bl salt_qual_ind_bl kero_qual_ind_bl") ///
				drop(_cons _Istrata* bl_var_mi bl_var) varlabels(treatment "Treatment" , elist(treatment \addlinespace) ) ///
				cells(b(star fmt(%12.2g) ) se(par(( )) fmt(%12.2g) ) qvalue(par([ ])  keep(treatment) fmt(2)) ) ///
				starlevels( * 0.10 ** 0.05 *** 0.01) ///
				stats(control_mean N percent_obs, label("Control mean" "Observations" "\% of sample") fmt(%12.2gc %15.0fc 0))

				

				
MultiPartTabEnd, ///
			ncol(`nc') tabname(`tabname') 
									
				
